sky.use(['dom','ajax','kalendae','flotr2'],function($,ajax){
	$('date').value = new Date().format('YYYY-MM-DD');
	new window.Kalendae.Input('date');

	function backFn(){
		var c = $('progress_list_' + this.prefix);
		if(this.error){
			c.innerHTML = '<p class="d_error_1">' + this.error + '</p>';
			return ;
		}
		var data = this.responseJSON.data || {};
		var list = i4.backDataSort((data));
		var max = list[1] + 20;
		list = list[0];

		var arr = sky.forEach(list,function(k){
			return [k,data[k]];
		},[]);
		window.Flotr.draw(c, [ arr ], {
			xaxis: {
				tickFormatter:function(num){
					return num + '点';
				},
				minorTickFreq: 4
			},
			yaxis:{
				tickFormatter:function(num){
					return num + 'KB';
				},
				max:max
			},
			grid: {
				minorVerticalLines: true
			}
		});
	}

	function sendFn(){
		var pm = {};
		pm.date = $('date').value.replace(/\D+/g,'');
		var from = $('from').value;
		var to = $('to').value;
		if(to < from){
			pm.from = to;
			pm.to = from;
		}
		else{
			pm.from = from;
			pm.to = to;
		}
		this.send(pm,true);
	}

	//查询
	var xSearchR = ajax.create('/info?name=rx&history=1','GET').extra({
		oncallback:backFn,
		get:sendFn,
		prefix:'r'
	});
	var xSearchT = ajax.create('/info?name=tx&history=1','GET').extra({
		oncallback:backFn,
		get:sendFn,
		prefix:'t'
	});

	function getData(){
		xSearchR.get();
		xSearchT.get();
	}
	$.vclick('search_btn',function(){
		getData();
	});

	getData();
});